package com.jiexin.controller;

import com.jiexin.common.ApplicationContextHelper;
import com.jiexin.common.JsonData;
import com.jiexin.dao.SysAclModuleMapper;
import com.jiexin.model.SysAclModule;
import com.jiexin.param.TestVo;
import com.jiexin.util.BeanValidator;
import com.jiexin.util.JsonMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @Author: Jay_Liu
 * @Description:
 * @Date: Created in 21:09 2018/3/30 0030
 * @Modified By:
 */
@Controller
@RequestMapping("/test")
@Slf4j
public class TestController {

    @RequestMapping("/hello.json")
    @ResponseBody
    public JsonData hello(){
        log.info("你好");
        throw new RuntimeException("test Exception");
        //return JsonData.success("hello,permission");
    }

    @RequestMapping("/validate.json")
    @ResponseBody
    public JsonData validate(TestVo vo){
        log.info("validate");
        SysAclModuleMapper moduleMapper = ApplicationContextHelper.popBean(SysAclModuleMapper.class);
        SysAclModule module = moduleMapper.selectByPrimaryKey(1);
        log.info(JsonMapper.obj2String(module));
        BeanValidator.check(vo);
        return JsonData.success("test validate");
    }

}
